import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)
const Rank = resolve => {
  import('components/rank/Rank').then((module) => {
    resolve(module)
  })
}
const TopList = resolve => {
  import('components/top-list/top-list').then((module) => {
    resolve(module)
  })
}
const Recommend = resolve => {
  import('components/recommend/Recommend').then((module) => {
    resolve(module)
  })
}
const Disc = resolve => {
  import('components/disc/disc').then((module) => {
    resolve(module)
  })
}
const Singer = resolve => {
  import('components/singer/Singer').then((module) => {
    resolve(module)
  })
}
const SingerDetail = resolve => {
  import('components/singer-detail/singer-detail').then((module) => {
    resolve(module)
  })
}
const Search = resolve => {
  import('components/search/search').then((module) => {
    resolve(module)
  })
}

export default new Router({
  routes: [
    { path: '/', redirect: '/recommend' },
    { path: '/search', component: Search },
    {
      path: '/recommend',
      component: Recommend,
      children: [
        {
          path: ':id',
          component: Disc
        }
      ]
    },
    {
      path: '/rank',
      component: Rank,
      children: [
        {
          path: ':id',
          component: TopList
        }
      ]
    },
    {
      path: '/singer',
      component: Singer,
      children: [
        {
          path: '/singer/:id',
          component: SingerDetail
        }
      ]
    }
  ]
})
